<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <script>

        // toFixed(n)   四舍五入的保留小数点后n位数
        // bug   结果是字符串    0.67789  通过把浮点数转为字符串，然后判断字符串的长度   

        var a = 0.1 ;
        var b = 0.2 ;
        var c = a + b ;
        c = c.toFixed(1) * 1;
        console.log(c);

        // 3.335.toFixed(2)     -> 3.33   失误

    </script>
    
</body>
</html>